﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace UserAuthen.Migrations
{
    /// <inheritdoc />
    public partial class allocation : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Supervisor1ID",
                table: "ExamRoomAllocation");

            migrationBuilder.DropForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Supervisor2ID",
                table: "ExamRoomAllocation");

            migrationBuilder.RenameColumn(
                name: "Supervisor2ID",
                table: "ExamRoomAllocation",
                newName: "Registration2ID");

            migrationBuilder.RenameColumn(
                name: "Supervisor1ID",
                table: "ExamRoomAllocation",
                newName: "Registration1ID");

            migrationBuilder.RenameIndex(
                name: "IX_ExamRoomAllocation_Supervisor2ID",
                table: "ExamRoomAllocation",
                newName: "IX_ExamRoomAllocation_Registration2ID");

            migrationBuilder.RenameIndex(
                name: "IX_ExamRoomAllocation_Supervisor1ID",
                table: "ExamRoomAllocation",
                newName: "IX_ExamRoomAllocation_Registration1ID");

            migrationBuilder.AddColumn<string>(
                name: "Name",
                table: "Registration",
                type: "TEXT",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AlterColumn<int>(
                name: "AllocationStatus",
                table: "ExamRoomAllocation",
                type: "INTEGER",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "TEXT");

            migrationBuilder.AddForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Registration1ID",
                table: "ExamRoomAllocation",
                column: "Registration1ID",
                principalTable: "Registration",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Registration2ID",
                table: "ExamRoomAllocation",
                column: "Registration2ID",
                principalTable: "Registration",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Registration1ID",
                table: "ExamRoomAllocation");

            migrationBuilder.DropForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Registration2ID",
                table: "ExamRoomAllocation");

            migrationBuilder.DropColumn(
                name: "Name",
                table: "Registration");

            migrationBuilder.RenameColumn(
                name: "Registration2ID",
                table: "ExamRoomAllocation",
                newName: "Supervisor2ID");

            migrationBuilder.RenameColumn(
                name: "Registration1ID",
                table: "ExamRoomAllocation",
                newName: "Supervisor1ID");

            migrationBuilder.RenameIndex(
                name: "IX_ExamRoomAllocation_Registration2ID",
                table: "ExamRoomAllocation",
                newName: "IX_ExamRoomAllocation_Supervisor2ID");

            migrationBuilder.RenameIndex(
                name: "IX_ExamRoomAllocation_Registration1ID",
                table: "ExamRoomAllocation",
                newName: "IX_ExamRoomAllocation_Supervisor1ID");

            migrationBuilder.AlterColumn<string>(
                name: "AllocationStatus",
                table: "ExamRoomAllocation",
                type: "TEXT",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "INTEGER");

            migrationBuilder.AddForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Supervisor1ID",
                table: "ExamRoomAllocation",
                column: "Supervisor1ID",
                principalTable: "Registration",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ExamRoomAllocation_Registration_Supervisor2ID",
                table: "ExamRoomAllocation",
                column: "Supervisor2ID",
                principalTable: "Registration",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
